<template>
  <div>
    <van-tabs v-model="activeName" @click="apple">
      <van-tab
        v-for="item in navDate"
        :key="item.id"
        :title="item.name"
        :name="item.id"
      >
        <ul>
          <li
            class="small"
            v-for="item in goodsList.data"
            :key="item.id"
            @click="goodsDesc(item)"
          >
            <img :src="item.list_pic_url" alt="" />
            <p>{{ item.name }}</p>
            <p class="brown">¥{{ item.retail_price }}</p>
          </li>
        </ul>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { categoryNav } from "@/api/category/list/index.js";
import { goods } from "@/api/category/list/index.js";
export default {
  data() {
    return {
      navDate: [],
      goodsList: [],
      activeName: ""
    };
  },

  computed: {},
  async created() {
    var result = await categoryNav({
      id: this.$route.query.id
    });
    this.navDate = result.navData;
    console.log(this.navDate);

    this.activeName = result.currentNav.id;

    var resultList = await goods({
      categoryId: this.$route.query.id
    });
    console.log(resultList);
    // this.currentOne = resultList.data;
    // console.log(resultList.data);
    this.goodsList = resultList;
  },
  mounted() {},
  methods: {
    apple(name, title) {
      var Id = String(name);
      goods({
        categoryId: Id
      }).then(res => {
        console.log(res);
        this.goodsList = res;
      });
    },

    goodsDesc(item) {
      this.$router.push({
        path: "/category/descript",
        query: {
          id: item.id
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.show {
  width: 100%;
  height: 150px;
  background-color: lightsalmon;
  margin-top: 20px;
}
.content {
  width: 100%;
  height: 3000px;
  background-color: #f5f5f5;
}
.small {
  width: 170px;
  height: 250px;
  background-color: #fff;
  float: left;
  margin-top: 10px;
  margin-right: 16px;
}
.small img {
  width: 150px;
  height: 180px;
}
.brown {
  color: brown;
}
</style>